package com.rockchips.mediacenter.view;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;

import com.rockchips.mediacenter.R;
import com.rockchips.mediacenter.bean.SmbInfo;
import com.rockchips.mediacenter.data.ConstData;
import com.rockchips.mediacenter.utils.ValidUtils;

import org.xutils.view.annotation.ViewInject;

import java.util.UUID;

import momo.cn.edu.fjnu.androidutils.utils.ResourceUtils;
import momo.cn.edu.fjnu.androidutils.utils.ToastUtils;

/**
 * @author GaoFei
 * 添加Samba设备网络对话框
 */
public class NetworkStreamSettingDialog extends AppBaseDialog{

	@ViewInject(R.id.edit_server_address)
	private EditText mEditServerAddress;
	@ViewInject(R.id.btn_ok)
	private Button mBtnOk;
	@ViewInject(R.id.btn_cancel)
	private Button mBtnCancel;

	public interface Callback{
		/**
		 * 回调函数，对话框确认关闭时的处理
		 */
		void onGetNetStreamInfo(String url);
	}

	private NetworkStreamSettingDialog.Callback mCallback;

	public NetworkStreamSettingDialog(Context context, NetworkStreamSettingDialog.Callback callback) {
		super(context);
		mCallback = callback;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//弹出输入法
		getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
	}

	@Override
	public int getLayoutRes() {
		return R.layout.dialog_net_stream_setting;
	}

	@Override
	public void initData() {
		//mEditServerAddress.setText("//10.10.10.130/share");
		//mEditServerAddress.setText("//10.10.10.164/Marshmallow_Repository");
		//mEditUserName.setText("sdk");
		//mEditPassword.setText("839919");
	}

	@Override
	public void initEvent() {
		mBtnOk.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String serverAddress = mEditServerAddress.getText().toString().trim();
				if(TextUtils.isEmpty(serverAddress)){
					ToastUtils.showToast(ResourceUtils.getString(R.string.enter_full));
					return;
				}
				mCallback.onGetNetStreamInfo(serverAddress);
				dismiss();
			}
		});
		
		mBtnCancel.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				dismiss();
			}
		});
	}


	
}
